<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Vite + Vue</title>
</head>

<body>
  <div id="app">
    <div class="res">等待中...</div>
    <button onclick="startDisplay()">开始抽取</button>
    <button onclick="stopDisplay()">停止抽取</button>
  </div>
  <script>
    const studentNames = ['毕平威',
      '陈香',
      '丁莉清',
      '冯德军',
      '郭子豪',
      '何意清',
      '何颖',
      '黄陶珏',
      '黄志炜',
      '雷源',
      '李海鹏',
      '李明阳',
      '李玉生',
      '利冰',
      '林清旺',
      '刘春敏',
      '刘文龙',
      '罗鑫',
      '孟维骏',
      '史航杰',
      '舒金涛',
      '苏琳琪',
      '王涛',
      '王艳丽',
      '邢梦婷',
      '熊俊杰',
      '杨文娟',
      '杨兴',
      '杨秀红',
      '叶德尧',
      '曾茂林',
      '张文蕾',
      '张治成',
      '赵长涛',
      '黄菲',
      '李永琴',
      '王华超',
      '王亚楠',
      '肖博文',
      '刘建瑞',
      '钟锦枫']

    let currentIndex = 0;
    let isStopped = false;

    function displayRandomStudentName() {
      if (isStopped) {
        return;
      }
      const studentName = studentNames[currentIndex];
      document.querySelector('.res').innerHTML = studentName;

      // 根据 studentNames 数组的长度, 取一个随机值作为 currentIndex
      currentIndex = Math.floor(Math.random() * studentNames.length);

      setTimeout(displayRandomStudentName, 60);
    }

    function startDisplay() {
      isStopped = false
      displayRandomStudentName()
    }

    function stopDisplay() {
      isStopped = true;
    }



  </script>
</body>

</html>